﻿using ET.Monitor.DAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class OtherModel
    {
        public OtherModel() { }
        string uid = "", desc = "", mid = "", tType = "", tOrgid = "";
        byte[] bt = null;

        public OtherModel(string uid, string desc, string org, string type, byte[] bt)
        {
            this.uid = uid;
            this.bt = bt;
            this.desc = desc;
            tOrgid = org;
            tType = type;
        }
        public OtherModel(string id, string user, string desc, string type, string orgid)
        {
            uid = user;
            this.desc = desc;
            mid = id;
            tType = type;
            tOrgid = orgid;
        }
        int pageCount = 1, pageIndex = 1;
        public OtherModel(int pageCount, int pageIndex, string uid)
        {
            this.uid = uid;
            this.pageCount = pageCount;
            this.pageIndex = pageIndex;
        }
        string id = "";
        public OtherModel(int pageCount, int pageIndex, string uid, string id)
        {
            this.uid = uid;
            this.pageCount = pageCount;
            this.pageIndex = pageIndex;
            this.id = id;
        }

        public OtherModel(string uid, string mid)
        {
            this.uid = uid;
            this.mid = mid;
        }
        DataSet ds = new DataSet();
        public OtherModel(DataSet ds, string mid)
        {
            this.ds = ds;
            this.mid = mid;
        }

        public OtherModel(string id)
        {
            mid = id;
        }
        string cid = "", cType = "", cName = "", cAttribute = "", cDesc = "", cParaId = "";
        public OtherModel(string cId, string cType, string desc, string cModelName, string cAttribute, string paraId)
        {
            this.cid = cId;
            this.cType = cType;
            this.cDesc = desc;
            this.cName = cModelName;
            this.cAttribute = cAttribute;
            this.cParaId = paraId;
        }
        string rid = "", oid = "";
        DateTime time = new DateTime();
        DateTime st = new DateTime();
        DateTime et = new DateTime();
        public OtherModel(string rid, string oid, DateTime time)
        {
            this.rid = rid;
            this.oid = oid;
            this.time = time;
        }

        int code = 1;
        string versioncode = "", type = "", name = "";
        public OtherModel(int code, string versioncode, string type, string desc, string name)
        {
            this.code = code;
            this.versioncode = versioncode;
            this.desc = desc;
            this.type = type;
            this.name = name;
        }

        OtherDAL dal = new OtherDAL();

        #region 保存模板
        bool model;

        public bool Model
        {
            get { return dal.AddModel(uid, desc, tOrgid, tType, bt); }
            set { model = value; }
        }
        #endregion

        #region 编辑模板
        bool editModel;
        public bool EditModel
        {
            get { return dal.EditModel(mid, uid, desc, tType, tOrgid); }
            set { editModel = value; }
        }

        #endregion

        #region 模板分页
        DataTable dtModel;

        public DataTable DtModel
        {
            get { return dal.GetModel(pageCount, pageIndex, uid); }
            set { dtModel = value; }
        }

        int modelPageCount;

        public int ModelPageCount
        {
            get { return dal.GetModelPageCount(mid); }
            set { modelPageCount = value; }
        }

        #endregion

        #region 删除模板
        bool delModel;

        public bool DelModel
        {
            get { return dal.DelModel(uid, mid); }
            set { delModel = value; }
        }
        #endregion

        #region 导入Excel
        bool upExcel;

        public bool UpExcel
        {
            get { return dal.AddExcel(ds, mid); }
            set { upExcel = value; }
        }
        #endregion

        #region 获取测点
        DataTable dtPoints;

        public DataTable DtPoints
        {
            get { return dal.GetPoints(mid); }
            set { dtPoints = value; }
        }
        #endregion

        #region 获取所有测点
        DataTable dtAllPoint;

        public DataTable DtAllPoint
        {
            get { return dal.GetPoints(); }
            set { dtAllPoint = value; }
        }
        #endregion

        #region 测点分页
        DataTable dtPaointsPage;

        public DataTable DtPaointsPage
        {
            get { return dal.GetPoints(uid, pageCount, pageIndex); }
            set { dtPaointsPage = value; }
        }
        int pointsPageCount;

        public int PointsPageCount
        {
            get { return dal.GetPointsPageCount(uid); }
            set { pointsPageCount = value; }
        }
        #endregion

        #region Chart Model Page
        DataTable dtChart;

        public DataTable DtChart
        {
            get { return dal.GetChartModel(id, uid, pageCount, pageIndex); }
            set { dtChart = value; }
        }

        int chartPageCount;

        public int ChartPageCount
        {
            get { return dal.GetChartModelPageCount(uid, mid); }
            set { chartPageCount = value; }
        }
        #endregion

        #region 获取模板信息
        DataTable dtModelInfo;

        public DataTable DtModelInfo
        {
            get { return dal.GetModelInfo(mid, uid); }
            set { dtModelInfo = value; }
        }
        #endregion

        #region 执行SQL
        DataTable dtSql;

        public DataTable DtSql
        {
            get { return dal.GetSqlVal(mid); }
            set { dtSql = value; }
        }
        #endregion

        #region 获取已有 Chart 模板数量
        int chartCount;

        public int ChartCount
        {
            get { return dal.GetChartModelCount(); }
            set { chartCount = value; }
        }
        #endregion

        #region 插入 Chart 模板
        bool addChartModel;

        public bool AddChartModel
        {
            get { return dal.AddChartModel(cid, cType, desc, cName, cAttribute, cParaId); }
            set { addChartModel = value; }
        }
        #endregion

        #region 获取所有 Chart Model
        DataTable dtChartModel;

        public DataTable DtChartModel
        {
            get { return dal.GetChartModel(); }
            set { dtChartModel = value; }
        }
        #endregion

        #region 报表

        #region 获取报表类型
        object oType;

        public object OType
        {
            get { return dal.GetReportType(mid); }
            set { oType = value; }
        }
        #endregion

        #region 获取 Word 报表
        DataTable dtWordReport;

        public DataTable DtWordReport
        {
            get { return dal.GetWordReport(rid, oid, time); }
            set { dtWordReport = value; }
        }
        #endregion

        #region 获取表格报表数据
        DataTable dtTableReport;

        public DataTable DtTableReport
        {
            get { return dal.GetTableReport(rid, oid, time); }
            set { dtTableReport = value; }
        }
        #endregion

        #region 获取报表所有参数
        DataTable dtReport;

        public DataTable DtReport
        {
            get { return dal.GetReport(rid, oid); }
            set { dtReport = value; }
        }
        #endregion
        #endregion

        #region 公共池数据

        DataTable dtPara;

        public DataTable DtPara
        {
            get { return dal.GetReportPara(); }
            set { dtPara = value; }
        }
        DataTable dtChartInfo;

        public DataTable DtChartInfo
        {
            get { return dal.GetRepartChart(); }
            set { dtChartInfo = value; }
        }
        #endregion


        #region 参数预警值
        object objWaringPara;
        public object ObjWaringPara
        {
            get
            {
                return dal.GetWarmingPara();
            }

            set
            {
                objWaringPara = value;
            }
        }


        #endregion

        #region 参数故障值
        object objFaultPara;
        public object ObjFaultPara
        {
            get
            {
                return dal.GetFaultPara();
            }

            set
            {
                objFaultPara = value;
            }
        }


        #endregion

        #region 电站停机值
        object objStationHalt;
        public object ObjStationHalt
        {
            get
            {
                return dal.GetStationHalt(); ;
            }

            set
            {
                objStationHalt = value;
            }
        }

        #endregion

        #region 电站预警值
        object objStationWaringPara;

        public object ObjStationWaringPara
        {
            get
            {
                return dal.GetStationWaringPara();
            }

            set
            {
                objStationWaringPara = value;
            }
        }

        #endregion



        bool boolSql;

        public bool BoolSql
        {
            get
            {
                return dal.runNonQuery(mid);
            }

            set
            {
                boolSql = value;
            }
        }

        bool blVersion;
        public bool BlVersion
        {
            get
            {
                return dal.AddVersion(code, versioncode, desc, type, name);
            }

            set
            {
                blVersion = value;
            }
        }

        DataTable dtVersion;
        public DataTable DtVersion
        {
            get
            {
                return dal.GetVersion(mid);
            }

            set
            {
                dtVersion = value;
            }
        }
    }
}
